#include"progress.h"

void text1()
{
    printf("这是一个测试代码！");
}


void version_1()
{
    char buffer[103];
    memset(buffer,'\0',sizeof(buffer));
    
    int count=0;
    buffer[0]=head;

    while(count<=100)
    {
        printf("[%-100s] [%d%%] []\r",buffer,count);
        fflush(stdout);
        buffer[count]=mov;
        count++;
        buffer[count]=head;
        
        if(count==100)
        {
            buffer[count]=mov;
        }
        usleep(50000);
    }
}


void version_2(float date)
{
    static char  buffer_1[103];
    char symbol[4]={'\\','|','/','~'};
    int n = (int)date;
    int k = rand()%4;
    buffer_1[n]= ' ';
    buffer_1[n+1]=head;

    char background[1]={0};

    if(date>=100.0)
    {
        buffer_1[n+1]=' ';
        printf("\033[0m\033[1;47;47m %-100s \033[0m \r",background);
        printf("\033[0m\033[1;47;42m %-100s \033[0m [%.2lf%%] [%c]\r", buffer_1,100.0 ,symbol[k]);
    }
    else
    {
        printf("\033[0m\033[1;47;47m%-100s\033[0m [%.2lf%%] [%c]\r",background,date,symbol[k]);
        printf("\033[1;47;42m][%s]\033[0m\r", buffer_1);
    }

    fflush(stdout);
    usleep(80000);
}
